# coding=utf-8
#


from django.db import models


class TidalAgent(models.Model):
    """ 潮汐实例 """

    STATUS_CHOICES = ((1, "运行中"),
                      (0, "已删除"))

    idc = models.CharField(max_length=64, verbose_name="机房")
    instance_id = models.CharField(max_length=128, verbose_name="实例ID")
    endpoint = models.CharField(max_length=255, verbose_name="接口endpoint，腾讯云需要", default="")
    zone = models.CharField(max_length=32, verbose_name="机房", default="")
    status = models.IntegerField(default=1, verbose_name="实例状态", choices=STATUS_CHOICES)
    create_time = models.DateTimeField(auto_now=False, auto_now_add=True, verbose_name="创建时间")
    update_time = models.DateTimeField(auto_now=True, verbose_name="修改时间")

    class Meta:
        ordering = ("-create_time",)
        verbose_name = "潮汐实例"
        verbose_name_plural = "潮汐实例管理"

        indexes = [
            models.Index(fields=["zone"], name="tidal_agent_zone"),
        ]

    def __str__(self):
        return self.instance_id

